<?php
try{
    $link=@mysql_connect("127.0.0.1","root","");
    if(!$link){
        throw new Exception("数据库连接错误：".mysql_error($link));
    }
    mysql_select_db("wenzhang");
    mysql_query("set names utf8");
}catch (Exception $e){
    echo $e->getMessage();
}